﻿using System;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.Workflow;

namespace CustomErrorPage.DueDateEventReceiver
{
    /// <summary>
    /// List Item Events
    /// </summary>
    public class DueDateEventReceiver : SPItemEventReceiver
    {
       /// <summary>
       /// An item is being added.
       /// </summary>
       public override void ItemAdding(SPItemEventProperties properties)
       {
           //base.ItemAdding(properties);
           if (properties.AfterProperties["Due Date"] == null)
           {
               properties.Status = SPEventReceiverStatus.CancelWithRedirectUrl;
               properties.RedirectUrl = 
               "/_layouts/CustomErrorPage/DueDateErrorPage.aspx";
           }
       }


    }
}
